<template>
	<view>
		<!-- 保证金缴纳 -->
		<view class="mainpadding_top">
			<view class="margin_top flexcolumn">
				<view class="titletext hei_text bold">实付金额</view>
				<view class="margin_top6 hei_text bold" style="font-size: 40rpx;">{{pay_price}}</view>
			</view>
			<view class="mainpadding_top  margin_top6 ffffff radius">
				<view class="flexbetween" @click="pay_type=10">
					<view class="flexleft">
						<u-icon name="weixin-circle-fill" color="#26db6f" size="28"></u-icon>
						<view class="titletext hei_text margin_left">微信</view>
					</view>
					<u-icon name="checkmark-circle-fill" v-if="pay_type==10" color="#2772F1" size="24"></u-icon>
					<u-icon name="checkmark-circle-fill" v-if="pay_type!=10" color="#999" size="24"></u-icon>
				</view>
			</view>
		</view>
		<view class="mainpadding gudingdb">
			<view class="bigbtn" @click="jifenPay()">立即支付</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				pay_price: "",
				tourist_id: "",
				tourist_tc_id:"",
				pay_type: 10,
			}
		},
		onLoad(options) {
			this.pay_price = options.pay_price
			this.tourist_id = options.tourist_id
			this.tourist_tc_id = options.tourist_tc_id
		},
		methods: {
			jifenPay() {
				let url = "/api/Travelcl/buyTouristTc"
				httpRequest.request(url, 'POST', {
					tourist_id: this.tourist_id,
					tourist_tc_id: this.tourist_tc_id,
				}).then(res => {
					if (res.code == 1) {
						let data = JSON.parse(res.data.wxconfig)
						uni.requestPayment({
							provider: 'wxpay',
							timeStamp: data.timeStamp,
							nonceStr: data.nonceStr,
							package: data.package,
							signType: data.signType,
							paySign: data.paySign,
							success: function(res) {
								// 支付成功
								uni.navigateBack(1)
							},
							fail: function(err) {
								// 支付失败
							}
						});
					} else {
						httpRequest.toast(res.msg)
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.iconclass {
		width: 40rpx;
		height: 40rpx;
	}
</style>